import {postBaseConfig} from "@/api/home.js";

export default {
  state: {
    showSearchButton: false,//搜索框
    pageQuery: {
      catalogId: '',//分类
      title: '',//标题
      publishedFlag: '1',//上架
      pageDomain: {
        pageNum: 1,
        pageSize: 8
      }
    },
   customerImg:''
  },
  mutations: {
    //搜索框是否显示
    changeSearchButton(state, flag) {
      state.showSearchButton = flag
    },
    // 变更分类
    changeCatalogId(state, id) {
      state.pageQuery.catalogId = id
      state.pageQuery.pageDomain.pageNum = 1
      state.pageQuery.title = ''
    },
    // 变更页数
    changeCatalogPageNum(state, pageNum) {
      state.pageQuery.pageDomain.pageNum = pageNum
    },
    // 变更查询条件
    changeCatalogTitle(state, title) {
      state.pageQuery.title = title
      state.pageQuery.pageDomain.pageNum = 1
    },
    changeCustomerImg(state, img) {
      state.customerImg = img
    },

  },
  actions: {
    getCustomerImg(context,value){
      postBaseConfig({ //区域id,非必填
        "code": "commonCode", }, res => {
        context.commit('changeCustomerImg',JSON.parse(res.data[0].value).find(item=>item.key=='customerImg').content)
      })

    }
  },
  getters: {

  }
}
